
package com.xtsoft.platform.base.system.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xtsoft.core.entity.GenericTreeEntity;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import jakarta.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * SysOrganize Base Java Bean, base class for the model, mapped directly to
 * database table
 * 
 * Avoid changing this file if not necessary, will be overwritten.
 *
 * TODO: add class/table comments
 */
@Entity
@Table(name = "sys_organize")
@Data
public class SysOrganize extends GenericTreeEntity<SysOrganize> {

	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name = "organizeId", nullable = false, length = 32)
	private String organizeId;

	/**
	 * 组织名称
	 */
	@Column(name = "organizeName", nullable = false, length = 128)
	private String organizeName;

	/**
	 * 组织机构编码
	 */
	@Column(name = "organizeCode", nullable = true, length = 128)
	private String organizeCode;

	/**
	 * 规模（0 大 1 中 2 小 3 微）
	 */
	@Column(name = "scaleId", nullable = true, length = 10)
	private Integer scaleId;

	/**
	 * 注册地址/住所
	 */
	@Column(name = "registerAddress", nullable = true, length = 128)
	private String registerAddress;

	/**
	 * 成立日期
	 */
	@Column(name = "establishDate", nullable = true, length = 19)
	private java.util.Date establishDate;

	/**
	 * 注册号/统一社会信用代码
	 */
	@Column(name = "registerNum", nullable = true, length = 64)
	private String registerNum;

	/**
	 * 公司网站
	 */
	@Column(name = "webSite", nullable = true, length = 64)
	private String webSite;

	/**
	 * 组织类型（0 企业 1 部门 3 商道 5 虚拟组织）
	 */
	@Column(name = "organizeType", nullable = false, length = 10)
	private Integer organizeType;

	/**
	 * 状态 0 禁用 1 可用
	 */
	@Column(name = "state", nullable = false, length = 10)
	private Integer state;
	
	/**
	 *  排序 在同层级企业/部门的排序
	 */
	@Column(name = "serialNo", nullable = false, length = 10)
	private Integer serialNo;
	

	/**
	 * 创建用户
	 */
	@Column(name = "createUserId", nullable = true, length = 32)
	private String createUserId;

	/**
	 * 编辑用户
	 */
	@Column(name = "editUserId", nullable = true, length = 32)
	private String editUserId;

	/**
	 * 编辑日期
	 */
	@Column(name = "editDate", nullable = true, length = 19)
	private java.util.Date editDate;

	/**
	 * 创建日期
	 */
	@Column(name = "createDate", nullable = true, length = 19)
	private java.util.Date createDate;

	/**
	 * 是否可用
	 */
	@Column(name = "isVisable", nullable = false, length = 10)
	private Integer isVisable;

	/**
	 * 业务类型
	 */
	@Column(name = "manageRange", nullable = true, length = 1024)
	private String manageRange;

	/**
	 * 企业标识
	 */
	@Column(unique = true, name = "nodeId", nullable = true, length = 64)
	private String nodeId;

	/**
	 * 上级企业标识
	 */
	@Column(name = "parentNodeId", nullable = true, length = 64)
	private String parentNodeId;

	/**
	 * 说明
	 */
	@Column(name = "descript", nullable = true, length = 255)
	private String descript;

	/**
	 * importedKeys
	 */
	@ManyToOne(fetch = FetchType.LAZY,optional=false)
	@JoinColumn(name = "sysTradeId", nullable = true)
	private SysTrade sysTrade;
	/**
	 * importedKeys
	 */
	@ManyToOne(fetch = FetchType.LAZY,optional=false)
	@JoinColumn(name = "regUniqueId")
	private SysRegion sysRegion;
	/**
	 * importedKeys
	 */
	@ManyToOne(fetch = FetchType.LAZY,optional=false)
	@JoinColumn(name = "sysOrganizeTypeId")
	private SysOrganizeType sysOrganizeType;

	
	@Transient
	public List<SysOrganize> list = new ArrayList<SysOrganize>();



	/*
	 * public void setChildren(List<SysOrganize> children) { this.super(children); }
	 */
	/*
	 * public List<SysOrganize> getChildren() { return this.getChildren(); //list; }
	 */

	/**
	 * 构建复选框树形结构 是否选中
	 */
	@Transient
	private Boolean checked;
	@Transient
	private Integer level;

	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "sysOrganize")
	@JsonIgnore
	private List<SysUser> sysUsers = new ArrayList();
	




	/**
	 * 以实体类主键生成HASHCODE
	 */
	@Override
	public int hashCode() {
		return this.organizeId.hashCode();
	}

	/**
	 * 以实体类主键比较对象是否相等
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof SysOrganize) {
			return this.organizeId.equals(((SysOrganize) obj).getOrganizeId());
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 */
	@Override
	public Integer getNodeSortValue() {
		// TODO Auto-generated method stub
		return null;
	}

}
